package com.jihox.abookpro.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

public class HomeViewPagerAdapter extends PagerAdapter{  
		  
        private List<View> mImageViews;

		public HomeViewPagerAdapter(List<View> mImageViews) {
			super();
			this.mImageViews = mImageViews;
		}


		@Override  
        public int getCount() {  
            return Integer.MAX_VALUE;  
        }  
		
		
        @Override  
        public boolean isViewFromObject(View arg0, Object arg1) {  
            return arg0 == arg1;  
        }  
  
        @Override  
        public void destroyItem(View container, int position, Object object) {  
//            ((ViewPager)container).removeView(mImageViews.get(position % mImageViews.size()));  
              
        }  
  
        /** 
         * 载入图片进去，用当前的position 除以 图片数组长度取余数是关键 
         */  
        @Override  
        public Object instantiateItem(View container, int position) {  
        	try{
            ((ViewPager)container).addView(mImageViews.get(position % mImageViews.size()), 0);  
        	}catch(Exception e){
        		
        	}
            return mImageViews.get(position % mImageViews.size());  
        }  
          
          
    }  